/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoopp.qcoinpay;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.Set;

public class r {
    private final LinkedHashMap a;
    private int b;
    private int c;
    private int d;
    private int e;
    private int f;
    private int g;

    public r(int paramInt) {
        if (paramInt <= 0)
            throw new IllegalArgumentException("maxSize <= 0");
        this.c = paramInt;
        this.a = new LinkedHashMap(0, 0.75F, true);
    }

    public final Object c(Object paramObject) {
        if (paramObject == null)
            throw new NullPointerException("key == null");
        synchronized (this) {
            if ((paramObject = this.a.get(paramObject)) != null) {
                this.f += 1;
                return paramObject;
            }
            this.g += 1;
        }
        return null;
    }

    public final Object a(Object paramObject1, Object paramObject2) {
        if ((paramObject1 == null) || (paramObject2 == null))
            throw new NullPointerException("key == null || value == null");
        synchronized (this) {
            this.d += 1;
            this.b += b(paramObject1, paramObject2);
            if ((paramObject2 = this.a.put(paramObject1, paramObject2)) != null)
                this.b -= b(paramObject1, paramObject2);
        }
        if (paramObject2 != null)
            b(paramObject2);
        a(this.c);
        return paramObject2;
    }

    public final void a(int paramInt) {
        while (true) {
            Object localObject2;
            synchronized (this) {
                if ((this.b < 0) || ((this.a.isEmpty()) && (this.b != 0)))
                    throw new IllegalStateException(super.getClass().getName()
                            + ".sizeOf() is reporting inconsistent results!");
                if (this.b <= paramInt)
                    return;
                if ((localObject2 = (this.a.entrySet().size() > 0) ? (Map.Entry) this.a.entrySet().iterator().next()
                        : null) == null)
                    return;
                Object localObject1 = localObject2.getKey();
                localObject2 = localObject2.getValue();
                this.a.remove(localObject1);
                this.b -= b(localObject1, localObject2);
                this.e += 1;
            }
            b(localObject2);
        }
    }

    protected void b(Object paramObject) {}

    private int b(Object paramObject1, Object paramObject2) {
        int i;
        if ((i = a(paramObject2)) < 0)
            throw new IllegalStateException("Negative size: " + paramObject1 + "=" + paramObject2);
        return i;
    }

    protected int a(Object paramObject) {
        return 1;
    }

    public final synchronized String toString() {
        int i = ((i = this.f + this.g) != 0) ? 100 * this.f / i : 0;
        return String.format(
                "LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]",
                new Object[] { Integer.valueOf(this.c), Integer.valueOf(this.f), Integer.valueOf(this.g),
                        Integer.valueOf(i) });
    }
}